
<%= javascript_include_tag '/javascripts/jquery', '/javascripts/graph/highcharts', '/javascripts/graph/pie', '/javascripts/graph/column', '/javascripts/graph/themes/grid', '/javascripts/graph/modules/exporting', '/javascripts/graph/column_percentage' %>


	<script type="text/javascript">
		var percentAll = {"Host unreachable" : 0, "RAM saturation" : 0, "WARNING ! disk almost full" : 0, "Disk full" : 0};
		var percentResolve = {"Host unreachable" : 0, "RAM saturation" : 0, "WARNING ! disk almost full" : 0, "Disk full" : 0};
		
		var labelPercent = new Array();		
		var libellePie = new Array();
		var valuePie = new Array();
		
		<% @incidentsPie.each do |incidentpie| %>
			percentAll["<%= incidentpie.incident_type %>"] = <%= incidentpie.resultat %>;
			libellePie.push("<%= incidentpie.incident_type %>");
			valuePie.push(<%= incidentpie.resultat %>);
			labelPercent.push("<%= incidentpie.incident_type %>");
		<% end %>

		<% @incidentsTauxCloture.each do |incidentpercent| %>
			percentResolve["<%= incidentpercent.incident_type %>"] = <%= incidentpercent.resultat %>;
		<% end %>
		
		var hostArray = new Array();
		var ramArray = new Array();
		var warningArray = new Array();
		var fullArray = new Array();
		var anono = {"Host unreachable" : 0, "RAM saturation" : 1, "WARNING ! disk almost full" : 2, "Disk full" : 3};
		
		<% @incidentsHist.each do |incidenthist| %>
			erreur = anono["<%= incidenthist.incident_type %>"];
			switch(erreur){
				case 0:
					hostArray["<%= incidenthist.date_anomalie %>"] = <%= incidenthist.resultat %>;
					break;
				case 1:
					ramArray["<%= incidenthist.date_anomalie %>"] = <%= incidenthist.resultat %>;
					break;
				case 2:
					warningArray["<%= incidenthist.date_anomalie %>"] = <%= incidenthist.resultat %>;
					break;
				case 3:
					fullArray["<%= incidenthist.date_anomalie %>"] = <%= incidenthist.resultat %>;
					break;
			}
		<% end %>
		pie(libellePie, valuePie, "<%= @machine.machine_name %>");
		column_percentage(labelPercent, percentResolve, percentAll, "<%= @machine.machine_name %>");
		column(hostArray, ramArray, warningArray, fullArray, "<%= @machine.machine_name %>", "<%= date_alone(@start) %>", "<%= date_alone(@end) %>");
		
	</script>
	<div id="display_table_incident">
		<div id="cadre_display">
			<%= image_tag("computer4.png", :size => "165x165") %> <br />
	    	<%=h @machine.machine_name %>
    	</div>
		
    <table class="table_incident">

		<tr>
			<td><b>Nom pc :</b></td>
			<td><%=h @machine.machine_name %></td>
		</tr>

		<tr>
			<td><b>Adresse IP :</b></td>
			<td><%=h @machine.ip_adr %></td>
		</tr>
			
		<tr>
			<td><b>Salle :</b></td>
			<td><%=h @machine.room.room_name %> </td>
		</tr>
		
		<tr>
			<td><b>Dernier état : </b></td>
			<td><%=h @machine.state %> </td>
		</tr>
		
		<tr>
			<td><b>Téléchargement log : </b></td>
			<td><%= link_to_remote 'dl', 
                 :url=>{:action=>'createCSV'},
                 :with => "'machine=' + #{@machine.id}"
%> </td>
		</tr>
	</table>
	</div>
	<noscript>pas de js activé donc tableau tout moche pas bô - Activez javascript pour avoir plus d'infos<br /><br />
	<table class="table">
		<tr>
			<th>Type d'incident</th>
			<th>Taux d'incident</th>
		</tr>
		<% @incidentsPie.each do |incidentpie| %>
			<tr>
				<td><%= incidentpie.incident_type %></td> 
				<td><%= incidentpie.resultat %></td>
			</tr>
		<% end %>
	</table>
	</noscript>
	<div id="pie_container" style="width:600px; height: 400px; margin-left: 600px; margin-bottom: 20px;"></div>
	<div id="column_percentage_container" style="width: 100%; height: 400px; margin-bottom: 20px;"></div>
	<div id="column_container" style="width: 100%; height: 400px"></div>
	